<template>
  <div style="margin:auto;width:400px;">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="用户名">
            <el-input v-model="form.userName"></el-input>
        </el-form-item>
        <el-form-item label="密码">
            <el-input v-model="form.pwd"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="login">登陆</el-button>
        </el-form-item>
      </el-form>
  </div>
</template>

<script>
export default {
    data(){
        return {
            form:{} //登陆表单对象
        }
    },
    methods:{
        //登陆方法
        async login(){
            //向服务器发送ajax请求，进行登陆验证
            var info = await this.ajax.getSubmit("/project/user/login",this.form);
            if(info == "ok"){//如果返回值为ok，跳转到index页面
                this.$router.push("/index");
            }
            else{
                alert("登陆失败");
            }
        }
    }
}
</script>

<style>

</style>